<?php
include  __DIR__.'/common/common.php';
$page=$_GET['page'];//获取页码
$page=(int)$page;
if ($page<1)
{
    $page=1;        //当得到的内容小于1转数字1
}
$data=mysqli_query($mysql,"SELECT COUNT(*) AS count FROM article");//统计一共有多少条数据
$count=mysqli_fetch_assoc($data);//array ( 'count' => '106', )
$count=$count['count'];
$start=(($page-1)*10);//起始位置
$data=mysqli_query($mysql,"SELECT * FROM article LIMIT $start,10");
$count=ceil($count/10);
$arr=array();
while ($a=mysqli_fetch_assoc($data))
{
    $arr[]=$a;
}
mysqli_free_result($data);
echo json_encode(array(
    'data'=>$arr,
    'count'=>$count
));//json格式输出